home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13013 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.7 KB

  1. Path: yoyo.cc.monash.edu.au!not-for-mail
  2. From: bcheung@yoyo.cc.monash.edu.au (Biggles Cheung)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Does C convert float to double internally ?
  5. Date: 3 Apr 1996 23:44:56 GMT
  6. Organization: Monash University
  7. Message-ID: <4jv2ho$r1o@harbinger.cc.monash.edu.au>
  8. References: <4jsllh$hkf@harbinger.cc.monash.edu.au>
  9. NNTP-Posting-Host: yoyo.cc.monash.edu.au
  10. X-NNTP-Posting-User: bcheung
  11. X-Newsreader: TIN [UNIX 1.3 950823BETA PL0]
  12.  
  13. Biggles Cheung (bcheung@yoyo.cc.monash.edu.au) wrote:
  14. : I was told that C compiler automatically converts "float" variable
  15. : internally to "double" for + - * / , etc operations. Is this true?
  16.  
  17. After I have read some books on C/C++, they all say that K&R C used to
  18. do _implicit_ conversion from float to double both in unary and binary
  19. operations, while ANSI C has dropped the implicit conversion and happily
  20. allows float to be float at all time.
  21.  
  22. Can I safely assume now that ALL current C/C++ compliers are following ANSI C
  23. standard?
  24.  
  25. : Can I force the C compiler not to do the conversion as I have an
  26. : assignment on finding out various computing errors of different
  27. : precisions? 
  28. :
  29.  
  30. I have read also the Turbo C++ manual and it says "tcc -ff- " command
  31. line option can force the command line compiler to follow STRICT ANSI C
  32. rule on conversion, i.e. no implicit conversion.
  33.  
  34. Can I now be sure that if I use "tcc -ff- program.c", there is _no_
  35. implicit conversion? But what about the IDE interface? 
  36.  
  37. Can someone suggest a simple program to test if there is any implicit
  38. conversion happening behind the curtain?
  39.  
  40.   
  41. : My advice from the lecturer is to have temporary variable of
  42. : float to split a long equation to smaller step so that I can maximize
  43. : the impact of single precision number on the evaluation. Is this
  44. : feasible?
  45.  
  46. If I am to find the single precision value of say, 12.3457 to the power
  47. of 13 by multiplying 12.3456 thirteen times, does that mean I have to
  48. store the result of every _single_ multiplication to a temporary variable
  49. of float to enforce the single precision? 
  50.  
  51. What if I have a very complicated mathematical expression like Taylor's
  52. series plus sqrt plus more ... ? How many temporary variables I need and
  53. when is the best time or where is the best spot to insert such
  54. _nuisance_?
  55.  
  56.  
  57. -- 
  58.  
  59.  
  60. _/\/\/\/\/\___/\/\_________________________/\/\_________________________
  61. _/\/\____/\/\__________/\/\/\/\___/\/\/\/\_/\/\_____/\/\/\_____/\/\/\/\_
  62. _/\/\/\/\/\___/\/\___/\/\__/\/\_/\/\__/\/\_/\/\___/\/\/\/\/\_/\/\/\/\___
  63. _/\/\____/\/\_/\/\_____/\/\/\/\___/\/\/\/\_/\/\___/\/\_____________/\/\_
  64. _/\/\/\/\/\___/\/\/\_______/\/\_______/\/\_/\/\/\___/\/\/\/\_/\/\/\/\___
  65. ____________________/\/\/\/\___/\/\/\/\_________________________________
  66.  
  67.     / biggles@c031.aone.net.au    \    
  68.     \ bcheung@yoyo.cc.monash.edu.au    / ~~ Biggles CHEUNG
  69.  
  70.  
  71.  
  72.